#include "QuickThread.h"

uiQuickThread::uiQuickThread(uiThreadRun* tb, void* param)
: m_tb(tb)
, m_param(param)
{
}

uiQuickThread::~uiQuickThread()
{

}

void* uiQuickThread::Entry()
{
	if(NULL == m_tb)
	{
		return NULL;
	}

	return m_tb->ThreadEntry(m_param);
}

bool uiQuickThread::CreateThread(uiThreadRun* tb /* = NULL */, void* param /* = NULL */)
{
	uiQuickThread		*qt		= new uiQuickThread(tb, param);

	if(wxTHREAD_NO_ERROR == qt->Create())
	{
		qt->Run();
		return true;
	}

	return false;
}

//////////////////////////////////////////////////////////////////////////
DEFINE_EVENT_TYPE(wxEVT_THREAD)
IMPLEMENT_DYNAMIC_CLASS(uiThreadEvent, wxEvent)

uiThreadEvent::uiThreadEvent(void* wParam /* = NULL */, void* lParam)
: wxEvent(0, wxEVT_THREAD)
, m_wParam(wParam)
, m_lParam(lParam)
{
	
}

wxEvent* uiThreadEvent::Clone() const
{
	return new uiThreadEvent(m_wParam, m_lParam);
}